//k1 edit 2021.12.18

if (!isServer) exitwith {};

private ["_center", "_staticWeaponClasses", "_parkedVehicleClasses"];
private ["_object", "_pos", "_marker", "_instanceNo", "_randomNo", "_gun", "_angle", "_car"];
_center = _this select 0;


_staticWeaponClasses = _this select 1;
_parkedVehicleClasses = _this select 2;
private _rotation = random 360;

[_center,25] call a3e_fnc_cleanupTerrain;

if (isNil "drn_BuildAmmoDepot_MarkerInstanceNo") then {
	drn_BuildAmmoDepot_MarkerInstanceNo = 0;
}
else {
	drn_BuildAmmoDepot_MarkerInstanceNo = drn_BuildAmmoDepot_MarkerInstanceNo + 1;
};
_instanceNo = drn_BuildAmmoDepot_MarkerInstanceNo;

_fnc_rotatePos = {
private ["_centerPos", "_pos", "_dir"];
private ["_px", "_py", "_mpx", "_mpy", "_ma", "_rpx", "_rpy"];
_centerPos = _this select 0;
_pos = _this select 1;
_dir = _this select 2;
    _px = _pos select 0;
    _py = _pos select 1;
    _mpx = _centerPos select 0;
    _mpy = _centerPos select 1;
    _ma = _dir;
    _rpx = ( (_px - _mpx) * cos(_ma) ) + ( (_py - _mpy) * sin(_ma) ) + _mpx;
    _rpy = (-(_px - _mpx) * sin(_ma) ) + ( (_py - _mpy) * cos(_ma) ) + _mpy;
[_rpx, _rpy, (_pos select 2)];
};

_pos = [_center,_center vectorAdd [5.35107,1.96094,0],_rotation] call _fnc_rotatePos;
_obj = "Land_SandbagBarricade_01_half_F" createvehicle _pos;
_obj setdir (270.538 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [0.589355,-4.96875,0],_rotation] call _fnc_rotatePos;
_obj = "Land_SandbagBarricade_01_half_F" createvehicle _pos;
_obj setdir (301.218 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [-13.7554,-5.25439,0],_rotation] call _fnc_rotatePos;
_obj1 = "Land_HBarrierTower_F" createvehicle _pos;
_obj1 setdir (90.4296 + _rotation);
_obj1 setPosATL _pos;

_pos = [_center,_center vectorAdd [12.79,4.13965,0],_rotation] call _fnc_rotatePos;
_obj2 = "Land_HBarrierTower_F" createvehicle _pos;
_obj2 setdir (268.177 + _rotation);
_obj2 setPosATL _pos;

_pos = [_center,_center vectorAdd [-8.32764,8.47119,0],_rotation] call _fnc_rotatePos;
_obj = "Land_HBarrier_Big_F" createvehicle _pos;
_obj setdir (0 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [-7.64697,-7.82861,0],_rotation] call _fnc_rotatePos;
_obj = "Land_HBarrier_Big_F" createvehicle _pos;
_obj setdir (0 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [8.61768,-7.10107,0],_rotation] call _fnc_rotatePos;
_obj = "Land_HBarrier_Big_F" createvehicle _pos;
_obj setdir (0 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [0.415039,8.88379,0],_rotation] call _fnc_rotatePos;
_obj = "Land_HBarrier_Big_F" createvehicle _pos;
_obj setdir (0 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [0.714355,-7.49854,0],_rotation] call _fnc_rotatePos;
_obj = "Land_HBarrier_Big_F" createvehicle _pos;
_obj setdir (0 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [9.05762,9.19678,0],_rotation] call _fnc_rotatePos;
_obj = "Land_HBarrier_Big_F" createvehicle _pos;
_obj setdir (0 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [13.6245,-3.54785,0],_rotation] call _fnc_rotatePos;
_obj = "Land_HBarrier_Big_F" createvehicle _pos;
_obj setdir (270.32 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [-15.7275,2.55518,0],_rotation] call _fnc_rotatePos;
_obj = "Land_HBarrierWall6_F" createvehicle _pos;
_obj setdir (269.802 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [13.3511,-2.03906,2.32366],_rotation] call _fnc_rotatePos;
_obj = "Land_PortableLight_double_F" createvehicle _pos;
_obj setdir (102.558 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [-11.0923,-2.38599,0],_rotation] call _fnc_rotatePos;
_obj = "MetalBarrel_burning_F" createvehicle _pos;
_obj setdir (254.972 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [-11.3647,7.89771,2],_rotation] call _fnc_rotatePos;
_obj = "Land_SignM_WarningMilitaryArea_english_F" createvehicle _pos;
_obj setdir (160.725 + _rotation);
_obj setPosATL _pos;

_pos = [_center,_center vectorAdd [-18.6489,5.96094,0],_rotation] call _fnc_rotatePos;
_obj = createVehicle ["FlagPole_F", _pos, [], 0, "NONE"];
_obj setdir (237.224 + _rotation);
_obj setPosATL _pos;
_obj setflagtexture A3E_VAR_Flag_Opfor;


    // Cars
	_parkedVehicleClasses append ["C_Heli_Light_01_civil_F","B_Heli_Light_01_F","I_Heli_light_03_unarmed_F"];
	_parkedVehicleClasses append ["O_Heli_Light_02_unarmed_F","C_IDAP_Heli_Transport_02_F"];
    if (random 10 > 1) then {
        _car = selectRandom _parkedVehicleClasses;
    }else{
        _car = "";
    };
    
    if (_car != "") then {
		_pos = [_center,_center vectorAdd [-0.566406,14.0417,0],_rotation] call _fnc_rotatePos;
		_obj = createvehicle [_car, [0,0,999], [], 0, "NONE"];
		_obj setdir (271 + _rotation);
		_obj setPosATL _pos;

		if !(_obj isKindOf "air") then {[_obj,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner};
		
		//_obj allowDamage false;
		Escape_all_assets pushback _obj;
		_obj setVariable ["Escape_assets_control", true, true];
    };

 // Statics
    
	_StaticWeapons = a3e_arr_Escape_SWC_MG_H + a3e_arr_Escape_SWC_GM_H;
    _gun = selectRandom _StaticWeapons;
	_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
	_static attachTo [_obj1,[-.5,-2,1.7]];
	detach _static;
	Escape_all_assets pushback _static;
	Escape_allStatics pushback _static;
	_static setVariable ["Escape_assets_control", true, true];
	
    _gun = selectRandom _StaticWeapons;
	_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
	_static attachTo [_obj2,[-.5,-2,1.7]];
	detach _static;
	Escape_all_assets pushback _static;
	Escape_allStatics pushback _static;
	_static setVariable ["Escape_assets_control", true, true];
	
	_StaticWeapons = a3e_arr_Escape_SWC_MG + a3e_arr_Escape_SWC_MG_H + a3e_arr_Escape_SWC_MG_A;
	if (random 10 > 1) then {
        _gun = selectRandom _StaticWeapons;
		_pos = [_center,_center vectorAdd [-7.66357,-5.00293,0.077373],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (331.122 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		Escape_allStatics pushback _static;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom _StaticWeapons;
		_pos = [_center,_center vectorAdd [11.2783,-4.65942,0.0773745],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (293.4 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		Escape_allStatics pushback _static;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom _StaticWeapons;
		_pos = [_center,_center vectorAdd [9.80566,5.82617,0.077373],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (270.3 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		Escape_allStatics pushback _static;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
		_pos = [_center,_center vectorAdd [-14.5186,-5.30884,4.24958],_rotation] call _fnc_rotatePos;
		_static = createVehicle [a3e_arr_MortarSite select(floor(random(count(a3e_arr_MortarSite)))), [0,0,999], [], 0, "NONE"]; //
		_static setdir (271.7 + _rotation);
		_static setPosATL _pos;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		Escape_all_assets pushback _static;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
		_pos = [_center,_center vectorAdd [13.6548,4.30103,4.24748],_rotation] call _fnc_rotatePos;
		_static = createVehicle [a3e_arr_MortarSite select(floor(random(count(a3e_arr_MortarSite)))), [0,0,999], [], 0, "NONE"]; //
		_static setdir (86.8 + _rotation);
		_static setPosATL _pos;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		Escape_all_assets pushback _static;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom a3e_arr_Escape_SWC_launcher_AT;
		_pos = [_center,_center vectorAdd [-14.0713,-12.0007,0.00477552],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (223.278 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom a3e_arr_Escape_SWC_launcher_AT;
		_pos = [_center,_center vectorAdd [-15.3809,11.071,0.00477219],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (297.105 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom a3e_arr_Escape_SWC_launcher_AT;
		_pos = [_center,_center vectorAdd [12.8569,-10.4084,0.00477457],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (179.523 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom a3e_arr_Escape_SWC_launcher_AT;
		_pos = [_center,_center vectorAdd [17.2563,13.1987,0.004776],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (48.72 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom a3e_arr_Escape_SWC_launcher_AA;
		_pos = [_center,_center vectorAdd [-0.636719,1.53955,0.00477219],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (270.73 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom a3e_arr_Escape_SWC_launcher_AA;
		_pos = [_center,_center vectorAdd [-0.48584,-1.91162,0.00477409],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (271.354 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom a3e_arr_Escape_SWC_launcher_AA;
		_pos = [_center,_center vectorAdd [2.52539,1.50171,0.00477552],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (0 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		_static setVariable ["Escape_assets_control", true, true];
	};
	if (random 10 > 1) then {
        _gun = selectRandom a3e_arr_Escape_SWC_launcher_AA;
		_pos = [_center,_center vectorAdd [2.72607,-1.42285,0.00477362],_rotation] call _fnc_rotatePos;
		_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
		_static setdir (186.25 + _rotation);
		_static setPosATL _pos;
		Escape_all_assets pushback _static;
		[_static,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
		_static setVariable ["Escape_assets_control", true, true];
	};



// Weapons
//_pos = [_center,_center vectorAdd [-0.278687,-7.39478,0],_rotation] call _fnc_rotatePos;
//_obj = "Box_Ammo_F" createvehicle _pos;
//_obj setVectorDirAndUp [[-0.999874,-0.0158694,0],[-0,0,1]];

    private ["_weapons", "_weaponMagazines", "_box", "_weaponCount"];

    // Basic Weapon Box
    
    _weapons = [];
    _weaponMagazines = [];
    
    for "_i" from 0 to (count a3e_arr_AmmoDepotBasicWeapons - 1) do {
        private ["_handGunItem", "_weaponClassName", "_probabilityOfPrecence", "_minCount", "_maxCount", "_magazines", "_magazinesPerWeapon"];
        
        _handGunItem = a3e_arr_AmmoDepotBasicWeapons select _i;
        
        _weaponClassName = _handGunItem select 0;
        _probabilityOfPrecence = _handGunItem select 1;
        _minCount = _handGunItem select 2;
        _maxCount = _handGunItem select 3;
        _magazines = _handGunItem select 4;
        _magazinesPerWeapon = _handGunItem select 5;
        
        if (random 100 <= _probabilityOfPrecence) then {
            _weaponCount = floor (_minCount + random (_maxCount - _minCount));
            _weapons pushBack [_weaponClassName, _weaponCount];
            
            for "_j" from 0 to (count _magazines) - 1 do {
                _weaponMagazines pushBack [_magazines select _j, _weaponCount * _magazinesPerWeapon];
            };
        };
    };
    
    if (count _weapons > 0 || {count _weaponMagazines > 0}) then {
        //_box = "Box_East_Wps_F" createVehicle [(_middlePos select 0) - 3, (_middlePos select 1) + 0, 0];
        //_box = createVehicle ["Box_East_Wps_F", [(_middlePos select 0) - 3, (_middlePos select 1) + 0, 0], [], 0, "CAN_COLLIDE"];
		
		_pos = [_center,_center vectorAdd [7.35107,0.960938,0],_rotation] call _fnc_rotatePos;
		_box = "Box_East_Wps_F" createvehicle _pos;
		_box setdir (270 + _rotation);
		_box setPosATL _pos;
		_box allowDamage false; //
		
        clearWeaponCargoGlobal _box;
        clearMagazineCargoGlobal _box;
        clearItemCargoGlobal _box;
		clearBackpackCargoGlobal _box;

        
        {
            _box addWeaponCargoGlobal _x;
        } foreach _weapons;
        
        {
            _box addMagazineCargoGlobal _x;
        } foreach _weaponMagazines;
    };

    // Special Weapon Box
    
    _weapons = [];
    _weaponMagazines = [];
    
    for "_i" from 0 to (count a3e_arr_AmmoDepotSpecialWeapons - 1) do {
        private ["_handGunItem", "_weaponClassName", "_probabilityOfPrecence", "_minCount", "_maxCount", "_magazines", "_magazinesPerWeapon"];
        
        _handGunItem = a3e_arr_AmmoDepotSpecialWeapons select _i;
        
        _weaponClassName = _handGunItem select 0;
        _probabilityOfPrecence = _handGunItem select 1;
        _minCount = _handGunItem select 2;
        _maxCount = _handGunItem select 3;
        _magazines = _handGunItem select 4;
        _magazinesPerWeapon = _handGunItem select 5;
        
        if (random 100 <= _probabilityOfPrecence) then {
            _weaponCount = floor (_minCount + random (_maxCount - _minCount));
            _weapons pushBack [_weaponClassName, _weaponCount];
            
            for "_j" from 0 to (count _magazines) - 1 do {
                _weaponMagazines pushBack [_magazines select _j, _weaponCount * _magazinesPerWeapon];
            };
        };
    };
    
    if (count _weapons > 0 || {count _weaponMagazines > 0}) then {
        //_box = "Box_East_WpsLaunch_F" createVehicle [(_middlePos select 0) + 3, (_middlePos select 1) + 0, 0];
		_pos = [_center,_center vectorAdd [9.35107,-3.03906,-4.76837e-007],_rotation] call _fnc_rotatePos;
		_box = "Box_East_WpsLaunch_F" createvehicle _pos;
		_box setdir (270 + _rotation);
		_box setPosATL _pos;
		_box allowDamage false; //
		
        clearWeaponCargoGlobal _box;
        clearMagazineCargoGlobal _box;
        clearItemCargoGlobal _box;
		clearBackpackCargoGlobal _box;
        
        {
            _box addWeaponCargoGlobal _x;
        } foreach _weapons;
        
        {
            _box addMagazineCargoGlobal _x;
        } foreach _weaponMagazines;
    };

	/*if((Param_Waffelbox)==1) then {
		_box = createVehicle [a3e_additional_weapon_box_1, [(_middlePos select 0) + 0, (_middlePos select 1) + 3, 0], [], 0, "CAN_COLLIDE"];
		_box = createVehicle [a3e_additional_weapon_box_2, [(_middlePos select 0) + 3, (_middlePos select 1) + 3, 0], [], 0, "CAN_COLLIDE"];
	 };*/
    // Ordnance
    
    _weapons = [];
    _weaponMagazines = [];
    
    for "_i" from 0 to (count a3e_arr_AmmoDepotOrdnance - 1) do {
        private ["_handGunItem", "_weaponClassName", "_probabilityOfPrecence", "_minCount", "_maxCount", "_magazines", "_magazinesPerWeapon"];
        
        _handGunItem = a3e_arr_AmmoDepotOrdnance select _i;
        
        _weaponClassName = _handGunItem select 0;
        _probabilityOfPrecence = _handGunItem select 1;
        _minCount = _handGunItem select 2;
        _maxCount = _handGunItem select 3;
        _magazines = _handGunItem select 4;
        _magazinesPerWeapon = _handGunItem select 5;
        
        if (random 100 <= _probabilityOfPrecence) then {
            _weaponCount = floor (_minCount + random (_maxCount - _minCount));
            _weapons pushBack [_weaponClassName, _weaponCount];
            
            for "_j" from 0 to (count _magazines) - 1 do {
                _weaponMagazines pushBack [_magazines select _j, _weaponCount * _magazinesPerWeapon];
            };
        };
    };
    
    if (count _weapons > 0 || {count _weaponMagazines > 0}) then {
        //_box = "Box_East_WpsSpecial_F" createVehicle [(_middlePos select 0) + 0, (_middlePos select 1) - 3, 0];
        //_box = createVehicle ["Box_East_WpsSpecial_F", [(_middlePos select 0) + 0, (_middlePos select 1) - 3, 0], [], 0, "CAN_COLLIDE"];
		
		_pos = [_center,_center vectorAdd [7.35107,-1.03906,0],_rotation] call _fnc_rotatePos;
		_box = "Box_East_WpsSpecial_F" createvehicle _pos;
		_box setdir (270 + _rotation);
		_box setPosATL _pos;
		_box allowDamage false; //
		
        clearWeaponCargoGlobal _box;
        clearMagazineCargoGlobal _box;
        clearItemCargoGlobal _box;
		clearBackpackCargoGlobal _box;
        
        {
            _box addWeaponCargoGlobal _x;
        } foreach _weapons;
        
        {
            _box addMagazineCargoGlobal _x;
        } foreach _weaponMagazines;
    };
    
    // Vehicle
    
    _weapons = [];
    _weaponMagazines = [];
    
    for "_i" from 0 to (count a3e_arr_AmmoDepotVehicle - 1) do {
        private ["_handGunItem", "_weaponClassName", "_probabilityOfPrecence", "_minCount", "_maxCount", "_magazines", "_magazinesPerWeapon"];
        
        _handGunItem = a3e_arr_AmmoDepotVehicle select _i;
        
        _weaponClassName = _handGunItem select 0;
        _probabilityOfPrecence = _handGunItem select 1;
        _minCount = _handGunItem select 2;
        _maxCount = _handGunItem select 3;
        _magazines = _handGunItem select 4;
        _magazinesPerWeapon = _handGunItem select 5;
        
        if (random 100 <= _probabilityOfPrecence) then {
            _weaponCount = floor (_minCount + random (_maxCount - _minCount));
            _weapons pushBack [_weaponClassName, _weaponCount];
            
            for "_j" from 0 to (count _magazines) - 1 do {
                _weaponMagazines pushBack [_magazines select _j, _weaponCount * _magazinesPerWeapon];
            };
        };
    };
	
	 _items = [];
	 for "_i" from 0 to (count a3e_arr_AmmoDepotVehicleItems - 1) do {
        private ["_item", "_itemClassName", "_probabilityOfPrecence", "_minCount", "_maxCount"];
        
        _item = a3e_arr_AmmoDepotVehicleItems select _i;
        
        _itemClassName = _item select 0;
        _probabilityOfPrecence = _item select 1;
        _minCount = _item select 2;
        _maxCount = _item select 3;
        
        if (random 100 <= _probabilityOfPrecence) then {
            _itemCount = floor (_minCount + random (_maxCount - _minCount));
            _items pushback [_itemClassName, _itemCount];
        };
    };
	
	
    if (count _weapons > 0 || {count _weaponMagazines > 0} || {count _items > 0}) then {
        //_box = "Box_NATO_AmmoVeh_F" createVehicle [(_middlePos select 0) + 0, (_middlePos select 1) + 0, 0];
        //_box = createVehicle ["Box_NATO_AmmoVeh_F", [(_middlePos select 0) + 0, (_middlePos select 1) + 0, 0], [], 0, "CAN_COLLIDE"];
		
		_pos = [_center,_center vectorAdd [9.35107,0.960938,0.0305414],_rotation] call _fnc_rotatePos;
		_box = "Box_NATO_AmmoVeh_F" createvehicle _pos;
		_box setdir (4.226 + _rotation);
		_box setPosATL _pos;
		_box allowDamage false; //

        clearWeaponCargoGlobal _box;
        clearMagazineCargoGlobal _box;
        clearItemCargoGlobal _box;
		clearBackpackCargoGlobal _box;
        
        {
            _box addWeaponCargoGlobal _x;
        } foreach _weapons;
        
        {
            _box addMagazineCargoGlobal _x;
        } foreach _weaponMagazines;
		{
            _box addBackpackCargoGlobal [_x,4];
        } foreach a3e_arr_AmmoDepotVehicleBackpacks;
		{
            _box addItemCargoGlobal _x;
        } foreach _items;
    };
    
    // Items

    _weapons = [];
    
    for "_i" from 0 to (count a3e_arr_AmmoDepotItems - 1) do {
        private ["_item", "_itemClassName", "_probabilityOfPrecence", "_minCount", "_maxCount"];
        
        _item = a3e_arr_AmmoDepotItems select _i;
        
        _itemClassName = _item select 0;
        _probabilityOfPrecence = _item select 1;
        _minCount = _item select 2;
        _maxCount = _item select 3;
        
        if (random 100 <= _probabilityOfPrecence) then {
            _itemCount = floor (_minCount + random (_maxCount - _minCount));
            _weapons pushBack [_itemClassName, _itemCount];
        };
    };
    
    if (count _weapons > 0) then {
        //_box = "Box_East_Wps_F" createVehicle [(_middlePos select 0) + 0, (_middlePos select 1) + 3, 0];
        //_box = createVehicle ["Box_East_Wps_F", [(_middlePos select 0) + 3, (_middlePos select 1) - 3, 0], [], 0, "CAN_COLLIDE"];

		_pos = [_center,_center vectorAdd [7.35107,-3.03906,0],_rotation] call _fnc_rotatePos;
		_box = "Box_East_Wps_F" createvehicle _pos;
		_box setdir (270 + _rotation);
		_box setPosATL _pos;
		_box allowDamage false; //

        clearWeaponCargoGlobal _box;
        clearMagazineCargoGlobal _box;
        clearItemCargoGlobal _box;
		clearBackpackCargoGlobal _box;
        
        {_box addItemCargoGlobal _x} foreach _weapons;
    };

    // Launchers
    
    _weapons = [];
    _weaponMagazines = [];
    
    for "_i" from 0 to (count a3e_arr_AmmoDepotLaunchers - 1) do {
        private ["_handGunItem", "_weaponClassName", "_probabilityOfPrecence", "_minCount", "_maxCount", "_magazines", "_magazinesPerWeapon"];
        
        _handGunItem = a3e_arr_AmmoDepotLaunchers select _i;
        
        _weaponClassName = _handGunItem select 0;
        _probabilityOfPrecence = _handGunItem select 1;
        _minCount = _handGunItem select 2;
        _maxCount = _handGunItem select 3;
        _magazines = _handGunItem select 4;
        _magazinesPerWeapon = _handGunItem select 5;
        
        if (random 100 <= _probabilityOfPrecence) then {
            _weaponCount = floor (_minCount + random (_maxCount - _minCount));
            _weapons set [count _weapons, [_weaponClassName, _weaponCount]];
            
            for "_j" from 0 to (count _magazines) - 1 do {
                _weaponMagazines set [count _weaponMagazines, [_magazines select _j, _weaponCount * _magazinesPerWeapon]];
            };
        };
    };
    
    if (count _weapons > 0 || {count _weaponMagazines > 0}) then {
        //_box = "Box_East_WpsLaunch_F" createVehicle [(_middlePos select 0) - 3, (_middlePos select 1) - 3, 0];
        //_box = createVehicle ["Box_East_WpsLaunch_F", [(_middlePos select 0) - 3, (_middlePos select 1) - 3, 0], [], 0, "CAN_COLLIDE"];
		
		_pos = [_center,_center vectorAdd [9.35107,-1.03906,-4.76837e-007],_rotation] call _fnc_rotatePos;
		_box = "Box_East_WpsLaunch_F" createvehicle _pos;
		_box setdir (270 + _rotation);
		_box setPosATL _pos;
		_box allowDamage false; //

        clearWeaponCargoGlobal _box;
        clearMagazineCargoGlobal _box;
        clearItemCargoGlobal _box;
		clearBackpackCargoGlobal _box;
        
        {_box addWeaponCargoGlobal _x} foreach _weapons;
        { _box addMagazineCargoGlobal _x} foreach _weaponMagazines;
    };
	
	Escape_campType_arr pushback [_center,"补给点","king"];
	publicVariable "Escape_campType_arr";

    // Set markers
    
    //_marker = createMarker ["drn_AmmoDepotMapMarker" + str _instanceNo, _middlePos];
    //_marker setMarkerType "o_installation";
      //_marker setMarkerType "o_installation";
	  
    ["drn_AmmoDepotMapMarker" + str _instanceNo,_center,"o_installation"] call A3E_fnc_createLocationMarker;

    _marker = createMarkerLocal ["drn_AmmoDepotPatrolMarker" + str _instanceNo, _center];
    _marker setMarkerShapeLocal "ELLIPSE";
    _marker setMarkerAlphaLocal 0;
    _marker setMarkerSizeLocal [50, 50];